<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
>

<p:dialog id="workflowPermissionDialog" widgetVar="workflowPermissionWidgetVar" modal="true" header="权限管理"
          resizable="false" width="1200" height="600">
    <div class="clearfix"
         style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
        <p:toolbar>
            <f:facet name="right">
                <p:commandButton value="保存" actionListener="#{workflowPermissionBean.onSave}"
                                 update="formNodeDataTable" oncomplete="PF('workflowPermissionWidgetVar').hide()"/>
            </f:facet>
        </p:toolbar>
    </div>
    <p:tabView id="permissionTabView" scrollable="true">
        <p:tab title="按钮权限">
        </p:tab>
        <p:tab title="表单权限">
        </p:tab>
        <p:tab title="流程启动权限">
            <div class="ui-g ui-fluid">
                <div class="ui-g-6">
                    <p:pickList value="#{workflowPermissionBean.userStarterDualListModel}"
                                var="starter"
                                itemLabel="#{starter.starterName}"
                                itemValue="#{starter.starter}"
                                showSourceFilter="true"
                                showTargetFilter="true"
                                filterMatchMode="contains"
                                responsive="true" converter="starterResponseDualListConverter">

                        <f:facet name="sourceCaption">用户列表</f:facet>
                        <f:facet name="targetCaption">已拥有权限用户</f:facet>

                    </p:pickList>
                </div>
                <div class="ui-g-6">
                    <p:pickList value="#{workflowPermissionBean.roleStarterDualListModel}"
                                var="starter"
                                itemLabel="#{starter.starterName}"
                                itemValue="#{starter.starter}"
                                showSourceFilter="true"
                                showTargetFilter="true"
                                filterMatchMode="contains"
                                responsive="true" converter="starterResponseDualListConverter">

                        <f:facet name="sourceCaption">角色列表</f:facet>
                        <f:facet name="targetCaption">已拥有权限角色</f:facet>

                    </p:pickList>
                </div>
            </div>
        </p:tab>
    </p:tabView>
</p:dialog>

<p:dialog id="workflowPermissionUserDialog" widgetVar="workflowPermissionUserWidgetVar" modal="true" header="选择用户"
          resizable="false" width="1200" height="600">
    <p:toolbar>
        <f:facet name="right">
            <p:commandButton value="查询" icon="fa fa-search"
                             update=":workflowDefinitionListForm:workflowPermissionUserDataTable"/>
            <p:commandButton value="提交" icon="fa fa-check" actionListener="#{workflowNodeBean.onSubmitUser}"
                             update="formNodeDataTable" oncomplete="PF('workflowNodeUserWidgetVar').hide()"/>
        </f:facet>
    </p:toolbar>
    <div class="ui-g ui-fluid">
        <div class="ui-g-12 card">
            <div class="ui-g-12"><h3><b>查询条件</b></h3></div>
            <p:panelGrid columns="4" layout="grid"
                         columnClasses="ui-grid-col-2,ui-grid-col-3,ui-grid-col-2,ui-grid-col-3"
                         styleClass="ui-panelgrid-blank"
                         style="border:0px none; background-color:transparent;">

                <p:outputLabel value="姓名"/>
                <p:inputText value="#{workflowNodeBean.systemUserSearchRequest.name}"/>

                <p:outputLabel value="用户名"/>
                <p:inputText value="#{workflowNodeBean.systemUserSearchRequest.account}"/>

                <p:outputLabel value="邮箱"/>
                <p:inputText value="#{workflowNodeBean.systemUserSearchRequest.email}"/>

                <p:outputLabel value="联系电话"/>
                <p:inputText value="#{workflowNodeBean.systemUserSearchRequest.phone}"/>

                <p:outputLabel value="是否启用"/>
                <p:selectOneMenu value="#{workflowNodeBean.systemUserSearchRequest.enable}">
                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                    <f:selectItem itemLabel="是" itemValue="true"/>
                    <f:selectItem itemLabel="否" itemValue="false"/>
                </p:selectOneMenu>

            </p:panelGrid>
            <div class="ui-g-12"><h3><b>用户列表</b></h3></div>
            <p:dataTable
                    id="workflowPermissionUserDataTable"
                    style="width: 100%"
                    var="user"
                    value="#{workflowNodeBean.systemUserLazyDataModel}"
                    rows="#{constants:get('ROWS')}"
                    lazy="true"
                    paginator="true"
                    paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                    rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                    emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                    reflow="true"
                    scrollable="true"
                    scrollWidth="97%"
                    resizableColumns="true">
                <p:column headerText="操作">
                    <p:commandButton value="选择" icon="fa fa-retweet"
                                     actionListener="#{workflowNodeBean.onSelectUser(user.account)}"
                                     update="workflowPermissionUserDataTable" process="@this"
                                     rendered="${!workflowNodeBean.isAssignedUser(user.account)}"/>
                    <p:commandButton value="取消" icon="fa fa-random"
                                     actionListener="#{workflowNodeBean.onUnselectUser(user.account)}"
                                     update="workflowPermissionUserDataTable" process="@this"
                                     rendered="${workflowNodeBean.isAssignedUser(user.account)}"/>
                </p:column>
                <p:column headerText="姓名">
                    <h:outputText value="#{user.name}"/>
                </p:column>
                <p:column headerText="用户名">
                    <h:outputText value="#{user.account}"/>
                </p:column>
                <p:column headerText="邮箱">
                    <h:outputText value="#{user.email}"/>
                </p:column>
                <p:column headerText="联系电话">
                    <h:outputText value="#{user.phone}"/>
                </p:column>
                <p:column headerText="合作机构">
                    <h:outputText value="#{user.partnerName}"/>
                </p:column>
                <p:column headerText="是否启用">
                    <h:outputText value="#{user.enable ? '是' : '否'}"/>
                </p:column>
            </p:dataTable>
        </div>
    </div>
</p:dialog>


<p:dialog id="workflowPermissionRoleDialog" widgetVar="workflowPermissionRoleWidgetVar" modal="true" header="选择角色"
          resizable="false" width="1200" height="600">
    <p:toolbar>
        <f:facet name="right">
            <p:commandButton value="查询" icon="fa fa-search"
                             update=":workflowDefinitionListForm:workflowPermissionRoleDataTable"/>
            <p:commandButton value="提交" icon="fa fa-check" actionListener="#{workflowNodeBean.onSubmitRole}"
                             update="formNodeDataTable" oncomplete="PF('workflowNodeRoleWidgetVar').hide()"/>
        </f:facet>
    </p:toolbar>
    <div class="ui-g ui-fluid">
        <div class="ui-g-12 card">
            <div class="ui-g-12"><h3><b>查询条件</b></h3></div>
            <p:panelGrid columns="4" layout="grid"
                         columnClasses="ui-grid-col-2,ui-grid-col-3,ui-grid-col-2,ui-grid-col-3"
                         styleClass="ui-panelgrid-blank"
                         style="border:0px none; background-color:transparent;">

                <p:outputLabel value="角色编码"/>
                <p:inputText value="#{workflowNodeBean.roleSearchRequest.code}"/>

                <p:outputLabel value="角色名称"/>
                <p:inputText value="#{workflowNodeBean.roleSearchRequest.name}"/>


                <p:outputLabel value="是否启用"/>
                <p:selectOneMenu value="#{workflowNodeBean.roleSearchRequest.enable}">
                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                    <f:selectItem itemLabel="是" itemValue="true"/>
                    <f:selectItem itemLabel="否" itemValue="false"/>
                </p:selectOneMenu>

            </p:panelGrid>
            <div class="ui-g-12"><h3><b>用户列表</b></h3></div>
            <p:dataTable
                    id="workflowPermissionRoleDataTable"
                    style="width: 100%"
                    var="role"
                    value="#{workflowNodeBean.roleLazyDataModel}"
                    rows="#{constants:get('ROWS')}"
                    lazy="true"
                    paginator="true"
                    paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                    rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                    emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                    reflow="true"
                    scrollable="true"
                    scrollWidth="97%"
                    resizableColumns="true">
                <p:column headerText="操作">
                    <p:commandButton value="选择" icon="fa fa-retweet"
                                     actionListener="#{workflowNodeBean.onSelectRole(role.code)}"
                                     update="workflowPermissionRoleDataTable" process="@this"
                                     rendered="${!workflowNodeBean.isAssignedRole(role.code)}"/>
                    <p:commandButton value="取消" icon="fa fa-random"
                                     actionListener="#{workflowNodeBean.onUnselectRole(role.code)}"
                                     update="workflowPermissionRoleDataTable" process="@this"
                                     rendered="${workflowNodeBean.isAssignedRole(role.code)}"/>
                </p:column>
                <p:column headerText="角色编码">
                    <h:outputText value="#{role.code}"/>
                </p:column>
                <p:column headerText="角色名称">
                    <h:outputText value="#{role.name}"/>
                </p:column>
                <p:column headerText="是否启用">
                    <h:outputText value="#{role.enable ? '是' : '否'}"/>
                </p:column>
            </p:dataTable>
        </div>
    </div>
</p:dialog>
</html>
